package low;

import java.util.Arrays;

/**
 * 344. 反转字符串
 */
public class ReverseString {
    public static void main(String[] args) {
        String str = "hello";
        char[] arrays = reverseString(str);
        System.out.println(Arrays.toString(arrays));
    }

    public static char[] reverseString(String str) {
        char[] chars = str.toCharArray();
        int left = 0;
        int right=chars.length-1;
        while (left<right){
            char tmp = chars[left];
            chars[left] = chars[right];
            chars[right] = tmp;
            left++;
            right--;
        }

        return chars;
    }
}
